<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div>
    <h1>异步注册测试</h1>
    <input type="text" placeholder="请输入用户名" @blur="f()" v-model="user.username">{{info}}<br>
    <input type="password" placeholder="请输入密码" v-model="user.password"><br>
    <input type="text" placeholder="请输入昵称" v-model="user.nickname"><br>
    <input type="button" value="注册" @click="reg()">
</div>


<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.min.js"></script>
<!-- import Vue before Element -->
<script src="https://cdn.staticfile.org/vue/2.6.14/vue.min.js"></script>
<!-- import JavaScript -->
<script src="https://cdn.staticfile.org/element-ui/2.15.9/index.min.js"></script>
<script>
    let v = new Vue({
        el: 'body>div',
        data: {
            user: {
                username: "",
                password: "",
                nickname: "",
            },
            info: ""
        },
        methods: {

            f() {
                axios.get("/selectUsername?username=" + v.user.username).then(function (response) {
                    v.info = response.data
                })
            },

            reg() {
                axios.post("/axiosReg", v.user).then(function (response) {

                })

            }
        }
    })
</script>
</body>
</html>